package com.digital.smartgrow.service.title;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.digital.smartgrow.dao.title.PracticeMapper;
import com.digital.smartgrow.dto.title.Practice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class PracticeServiceImpl implements PracticeService{


    @Autowired
    PracticeMapper practiceMapper;


    @Override
    @Transactional
    public List<Practice> findList(Practice practice) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("status", 0);
        queryWrapper.eq("idcard", practice.getIdcard());
        return practiceMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public void delete(Practice practice) {
        Practice practice1 = new Practice();
        Date date = new Date();
        practice1.setId(practice.getId()).setStatus(1).setTime(date);
        practiceMapper.updateById(practice1);
    }
}
